# Maintainer: David Runge <dvzrv@archlinux.org>

_name=django-gravatar2
pkgname=python-django-gravatar
pkgver=1.4.4
pkgrel=6
pkgdesc="Essential Gravatar support for Django"
arch=('any')
url="https://github.com/twaddington/django-gravatar"
license=('MIT')
depends=('python-django')
makedepends=('python-setuptools')
checkdepends=('python-pytest')
source=("https://files.pythonhosted.org/packages/source/${_name::1}/${_name}/${_name}-${pkgver}.tar.gz")
sha512sums=('999fe2a036b23f73ee8111cccde459aa72a5f90995d322e772776f85ba206281e791cdf7d4888b45c7f2ecf8baf6509ed44652396f5db158c484a2fb53439c99')

prepare() {
  mv -v "${_name}-${pkgver}" "$pkgname-$pkgver"
}

build() {
  cd "$pkgname-$pkgver"
  python setup.py build
}

check() {
  cd "$pkgname-$pkgver"
  export PYTHONPATH="build:${PYTHONPATH}"
  python example_project/manage.py test --verbosity=2 django_gravatar
}

package() {
  cd "$pkgname-$pkgver"
  python setup.py install --skip-build \
    --optimize=1 \
    --prefix=/usr \
    --root="${pkgdir}"
  install -vDm 644 README.rst -t "${pkgdir}/usr/share/doc/${pkgname}"
  install -vDm 644 LICENSE -t "${pkgdir}/usr/share/licenses/${pkgname}"
}
